package com.holyn.guofang.view.my;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;

import com.holyn.guofang.R;
import com.holyn.guofang.view.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Holyn on 2017/8/29.
 */

public class MyRechargeAddressActivity extends BaseActivity {
    public final static String INTENT_KEY_ADDRESS_ALL = "INTENT_KEY_ADDRESS_ALL";

    @BindView(R.id.et_company)
    EditText etCompany;
    @BindView(R.id.et_name)
    EditText etName;
    @BindView(R.id.et_address)
    EditText etAddress;
    @BindView(R.id.et_mobile)
    EditText etMobile;
    @BindView(R.id.et_email)
    EditText etEmail;
    @BindView(R.id.btn_submit)
    Button btnSubmit;

    public static void start(Activity activity, int requestCode){
        Intent intent = new Intent(activity, MyRechargeAddressActivity.class);
        activity.startActivityForResult(intent, requestCode);
    }

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_my_recharge_address;
    }

    @Override
    protected void onMyCreate() {
        ButterKnife.bind(this);
        showToolbar("附属卡地址");

    }

    @OnClick(R.id.btn_submit)
    public void onViewClicked() {
        String company = etCompany.getText().toString().trim();
        String name = etName.getText().toString().trim();
        String address = etAddress.getText().toString().trim();
        String mobile = etMobile.getText().toString().trim();
        String email = etEmail.getText().toString().trim();

        String result = company;
        if (!TextUtils.isEmpty(name)){
            result = result + "-" +name;
        }
        if (!TextUtils.isEmpty(address)){
            result = result + "-" +address;
        }
        if (!TextUtils.isEmpty(mobile)){
            result = result + "-" +mobile;
        }
        if (!TextUtils.isEmpty(email)){
            result = result + "-" +email;
        }
        Intent intent = getIntent();
        intent.putExtra(INTENT_KEY_ADDRESS_ALL, result);
        setResult(Activity.RESULT_OK, intent);
    }
}
